home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / progwin.zip / DEVCAPS1.ZIP / DEVCAPS.C next >
C/C++ Source or Header  |  1991-11-01  |  8KB  |  215 lines

  1. /*---------------------------------------------------------
  2.    DEVCAPS.C -- Display routines for DEVCAPS1 and DEVCAPS2
  3.                 (c) Charles Petzold, 1990
  4.   ---------------------------------------------------------*/
  5.  
  6. #include <windows.h>
  7. #include <string.h>
  8. #include <stdio.h>
  9.  
  10. typedef struct
  11. {
  12.   short nMask;
  13.   char *szMask;
  14.   char *szDesc;
  15. } BITS;
  16.  
  17. void DoBasicInfo(HDC hdc, HDC hdcInfo, short cxChar, short cyChar)
  18. {
  19.   static struct
  20.   {
  21.     short nIndex;
  22.     char *szDesc;
  23.   }
  24.   info[] =
  25.   {
  26.     HORZSIZE,    "HORZSIZE    Width in millimeters:",
  27.     VERTSIZE,    "VERTSIZE    Height in millimeters:",
  28.     HORZRES,     "HORZRES     Width in pixels:",
  29.     VERTRES,     "VERTRES     Height in raster lines:",
  30.     BITSPIXEL,   "BITSPIXEL   Color bits per pixel:",
  31.     PLANES,      "PLANES      Number of color planes:",
  32.     NUMBRUSHES,  "NUMBRUSHES  Number of device brushes:",
  33.     NUMPENS,     "NUMBPENS    Number of device pens:",
  34.     NUMMARKERS,  "NUMMARKERS  Number of device markers:",
  35.     NUMFONTS,    "NUMFONTS    Number of device fonts:",
  36.     NUMCOLORS,   "NUMCOLORS   Number of device colors:",
  37.     PDEVICESIZE, "PDEVICESIZE Size of device structure:",
  38.     ASPECTX,     "ASPECTX     Relative width of pixel:",
  39.     ASPECTY,     "ASPECTY     Relative height of pixel:",
  40.     ASPECTXY,    "ASPECTXY    Relative diagonal of pixel:",
  41.     LOGPIXELSX,  "LOGPIXELSX  Horizontal dots per inch:",
  42.     LOGPIXELSY,  "LOGPIXELSY  Vertical dots per inch:",
  43.     SIZEPALETTE, "SIZEPALETTE Number of palette entries:",
  44.     NUMRESERVED, "NUMRESERVED Reserverd palette entries:",
  45.     COLORRES,    "COLORRES    Actual color resolution:"
  46.   };
  47.  
  48.   char szBuffer[80];
  49.   short i,nLine;
  50.  
  51.   for (i=0; i<sizeof info / sizeof info[0]; i++)
  52.     TextOut(hdc, cxChar, (i+1)*cyChar, szBuffer,
  53.       sprintf(szBuffer, "%-40s%8d", info[i].szDesc,
  54.         GetDeviceCaps(hdcInfo, info[i].nIndex)));
  55.  
  56. }
  57.  
  58. void DoOtherInfo(HDC hdc, HDC hdcInfo, short cxChar, short cyChar)
  59. {
  60.   static BITS clip[] =
  61.   {
  62.     CP_RECTANGLE, "CP_RECTANGLE", "Can clip to rectangle:"
  63.   };
  64.  
  65.   static BITS raster[] =
  66.   {
  67.     RC_BITBLT,       "RC_BITBLT",       "Capable of simple BitBlt:",
  68.     RC_BANDING,      "RC_BANDING",      "Requires banding support:",
  69.     RC_SCALING,      "RC_SCALING",      "Requires scaling support:",
  70.     RC_BITMAP64,     "RC_BITMAP64",     "Supports bitmaps >64K:",
  71.     RC_GDI20_OUTPUT, "RC_GDI20_OUTPUT", "Has 2.0 output calls:",
  72.     RC_DI_BITMAP,    "RC_DI_BITMAP",    "Supports DIB to memory:",
  73.     RC_PALETTE,      "RC_PALETTE",      "Supports a palette:",
  74.     RC_DIBTODEV,     "RC_DIBTODEV",     "Supports bitmap conversion:",
  75.     RC_BIGFONT,      "RC_BIGFONT",      "Supports fonts >64K:",
  76.     RC_STRETCHBLT,   "RC_STRETCHBLT",   "Supports StretchBlt:",
  77.     RC_FLOODFILL,    "RC_FLOODFILL",    "Supports FloodFill:"
  78.   };
  79.  
  80.   static char *szTech[] =
  81.   {
  82.     "DT_PLOTTER (Vector plotter)",
  83.     "DT_RASDISPLAY (Raster display)",
  84.     "DT_RASPRINTER (Raster printer)",
  85.     "DT_RASCAMERA (Raster camera)",
  86.     "DT_CHARSTREAM (Character-stream, PLP)",
  87.     "DT_METAFILE (Metafile, VDM)",
  88.     "DT_DISPFILE (Display-file)"
  89.   };
  90.  
  91.   char szBuffer[80];
  92.   short i;
  93.  
  94.   TextOut(hdc, cxChar, cyChar, szBuffer,
  95.           sprintf(szBuffer, "%-24s%04XH",
  96.           "DRIVERVERSION:", GetDeviceCaps(hdcInfo, DRIVERVERSION)));
  97.  
  98.   TextOut(hdc, cxChar, 2 * cyChar, szBuffer,
  99.           sprintf(szBuffer, "%-24s%-40s",
  100.           "TECHNOLOGY:",szTech[GetDeviceCaps(hdcInfo, TECHNOLOGY)]));
  101.  
  102.   TextOut(hdc, cxChar, 4 * cyChar, szBuffer,
  103.           sprintf(szBuffer, "CLIPCAPS (Clipping capabilities)"));
  104.  
  105.   for (i=0; i< sizeof clip / sizeof clip[0]; i++)
  106.        TextOut(hdc, 9 * cxChar, (i+6) * cyChar, szBuffer,
  107.                sprintf(szBuffer, "%-16s%-28s %3s",
  108.                        clip[i].szMask, clip[i].szDesc,
  109.                        GetDeviceCaps(hdcInfo, CLIPCAPS) & clip[i].nMask ?
  110.                             "Yes" : "No"));
  111.  
  112.   TextOut(hdc, cxChar, 8 * cyChar, szBuffer,
  113.           sprintf(szBuffer, "RASTERCAPS (Raster capabilities)"));
  114.  
  115.   for (i=0; i < sizeof raster / sizeof raster[0]; i++)
  116.        TextOut(hdc, 9 * cxChar, (i+10) * cyChar, szBuffer,
  117.             sprintf(szBuffer, "%-16s%-28s %3s",
  118.                raster[i].szMask, raster[i].szDesc,
  119.                GetDeviceCaps(hdcInfo, RASTERCAPS) & raster[i].nMask ?
  120.                  "Yes" : "No"));
  121.  
  122. }
  123.  
  124. void DoBitCodedCaps (HDC hdc, HDC hdcInfo, short cxChar, short cyChar,
  125.                      short nType)
  126. {
  127.   static BITS curves[] =
  128.   {
  129.     CC_CIRCLES,    "CC_CIRCLES",    "circles:",
  130.     CC_PIE,        "CC_PIE",        "pie wedges:",
  131.     CC_CHORD,      "CC_CHORD",      "chord arcs:",
  132.     CC_ELLIPSES,   "CC_ELLIPSES",   "ellipses:",
  133.     CC_WIDE,       "CC_WIDE",       "wide borders:",
  134.     CC_STYLED,     "CC_STYLED",     "styled borders:",
  135.     CC_WIDESTYLED, "CC_WIDESTYLED", "wide and styled borders:",
  136.     CC_INTERIORS,  "CC_INTERIORS",  "interiors:"
  137.   };
  138.  
  139.   static BITS lines[] =
  140.   {
  141.     LC_POLYLINE,   "LC_POLYLINE",   "polylines:",
  142.     LC_MARKER,     "LC_MARKER",     "markers:",
  143.     LC_POLYMARKER, "LC_POLYMARKER", "polymarkers:",
  144.     LC_WIDE,       "LC_WIDE",       "wide lines:",
  145.     LC_STYLED,     "LC_STYLED",     "styled lines:",
  146.     LC_WIDESTYLED, "LC_WIDESTYLED", "wide and styled lines:",
  147.     LC_INTERIORS,  "LC_INTERIORS",  "interiors:"
  148.   };
  149.  
  150.   static BITS poly[] =
  151.   {
  152.     PC_POLYGON,    "PC_POLYGON",    "alternate fill polygon:",
  153.     PC_RECTANGLE,  "PC_RECTANGLE",  "rectangles:",
  154.     PC_TRAPEZOID,  "PC_TRAPEZOID",  "winding number fill polygon:",
  155.     PC_SCANLINE,   "PC_SCANLINE",   "scanlines:",
  156.     PC_WIDE,       "PC_WIDE",       "wide borders:",
  157.     PC_STYLED,     "PC_STYLED",     "styled borders:",
  158.     PC_WIDESTYLED, "PC_WIDESTYLED", "wide and styled borders:",
  159.     PC_INTERIORS,  "PC_INTERIORS",  "interiors:"
  160.   };
  161.  
  162.   static BITS text[] =
  163.   {
  164.     TC_OP_CHARACTER, "TC_OP_CHARACTER", "character output precision:",
  165.     TC_OP_STROKE,    "TC_OP_STROKE",    "stroke output precision:",
  166.     TC_CP_STROKE,    "TC_CP_STROKE",    "stroke clip precision:",
  167.     TC_CR_90,        "TC_CR_90",        "90-degree character rotation:",
  168.     TC_CR_ANY,       "TC_CR_ANY",       "any character rotation:",
  169.     TC_SF_X_YINDEP,  "TC_SF_X_YINDEP",  "scaling independent of x and y:",
  170.     TC_SA_DOUBLE,    "TC_SA_DOUBLE",    "doubled character for scaling:",
  171.     TC_SA_INTEGER,   "TC_SA_INTEGER",   "integer multiples for scaling:",
  172.     TC_SA_CONTIN,    "TC_SA_CONTIN",    "any multiples for exact scaling:",
  173.     TC_EA_DOUBLE,    "TC_EA_DOUBLE",    "double-weight characters:",
  174.     TC_IA_ABLE,      "TC_IA_ABLE",      "italicizing:",
  175.     TC_UA_ABLE,      "TC_UA_ABLE",      "underlining:",
  176.     TC_SO_ABLE,      "TC_SO_ABLE",      "strikeouts:",
  177.     TC_RA_ABLE,      "TC_RA_ABLE",      "raster fonts:",
  178.     TC_VA_ABLE,      "TC_VA_ABLE",      "vector fonts:"
  179.   };
  180.  
  181.   static struct
  182.   {
  183.     short nIndex;
  184.     char *szTitle;
  185.     BITS (*pbits)[];
  186.     short nSize;
  187.   }
  188.   bitinfo[] =
  189.   {
  190.     CURVECAPS, "CURVCAPS (Curve capabilities)",
  191.               (BITS (*)[]) curves, sizeof curves / sizeof curves[0],
  192.     LINECAPS, "LINECAPS (Line capabilities)",
  193.               (BITS (*)[]) lines, sizeof lines / sizeof lines[0],
  194.     POLYGONALCAPS, "POLYGONALCAPS (Polygonal capabilities)",
  195.               (BITS (*)[]) poly, sizeof poly / sizeof poly[0],
  196.     TEXTCAPS, "TEXTCAPS (Text capabilities)",
  197.               (BITS (*)[]) text, sizeof text / sizeof text[0]
  198.   };
  199.  
  200.   static char szBuffer[80];
  201.   BITS (*pbits)[] = bitinfo[nType].pbits;
  202.   short nDevCaps = GetDeviceCaps(hdcInfo, bitinfo[nType].nIndex);
  203.   short i;
  204.  
  205.   TextOut(hdc, cxChar, cyChar, bitinfo[nType].szTitle,
  206.                strlen(bitinfo[nType].szTitle));
  207.  
  208.   for (i=0; i < bitinfo[nType].nSize; i++)
  209.        TextOut(hdc, cxChar, (i+3)*cyChar, szBuffer,
  210.             sprintf(szBuffer, "%-16s %s %-32s %3s",
  211.                (*pbits)[i].szMask, "Can do", (*pbits)[i].szDesc,
  212.                nDevCaps & (*pbits)[i].nMask ? "Yes" : "No"));
  213.  
  214. }
  215.